summaryrefslogtreecommitdiff
path: root/src/pages/[...blog]/[...page].astro
blob: 5a6da41ea89e31e3ec52218f876fab4fc1a5caa9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
import type { InferGetStaticPropsType, GetStaticPaths } from 'astro';

import Layout from '~/layouts/PageLayout.astro';
import BlogList from '~/components/blog/List.astro';
import Headline from '~/components/blog/Headline.astro';
import Pagination from '~/components/blog/Pagination.astro';
// import PostTags from "~/components/blog/Tags.astro";

import { blogListRobots, getStaticPathsBlogList } from '~/utils/blog';

export const prerender = true;

export const getStaticPaths = (async ({ paginate }) => {
  return await getStaticPathsBlogList({ paginate });
}) satisfies GetStaticPaths;

type Props = InferGetStaticPropsType<typeof getStaticPaths>;

const { page } = Astro.props as Props;
const currentPage = page.currentPage ?? 1;

// const allCategories = await findCategories();
// const allTags = await findTags();

const metadata = {
  title: `Blog${currentPage > 1 ? ` — Page ${currentPage}` : ''}`,
  robots: {
    index: blogListRobots?.index && currentPage === 1,
    follow: blogListRobots?.follow,
  },
  openGraph: {
    type: 'blog',
  },
};
---

<Layout metadata={metadata}>
  <section class="px-6 sm:px-6 py-12 sm:py-16 lg:py-20 mx-auto max-w-4xl">
    <Headline
      subtitle="A statically generated blog example with news, tutorials, resources and other interesting content related to AstroWind"
    >
      The Blog
    </Headline>
    <BlogList posts={page.data} />
    <Pagination prevUrl={page.url.prev} nextUrl={page.url.next} />
    <!--
      <PostTags tags={allCategories} class="mb-2" title="Search by Categories:" isCategory />
      <PostTags tags={allTags}  title="Search by Tags:" />
    -->
  </section>
</Layout>